<template>
  <view class="container screen-width">
    <view v-if="searchList.length" class="list-content">
      <view v-for="(item, index) in searchList" :key="index" class="list-item" @click="toDetail(item.id)">
        <view class="com-info">文件名称：{{ item.fileName || '--' }}</view>
        <view class="com-info">检测时间：{{ item.createTime }}</view>
        <view class="com-info"
          >完整度：<text>{{ item.completionDegree }}%</text></view
        >
      </view>
      <van-divider v-if="searchList.length && total < searchList.length + 1" content-position="center">我也是有底线的</van-divider>
    </view>
    <van-divider v-else content-position="center">暂无数据</van-divider>
  </view>
</template>
<script>
  import { list } from '@/util/api/business.js'
  export default {
    data() {
      return {
        search: {
          pageNo: 1,
          pageSize: 10,
        },
        total: 0,
        searchList: [],
      }
    },
    onLoad() {
      this.getList()
    },
    onReachBottom() {
      if (this.searchList.length >= this.total) return
      this.search.pageNo += 1
      this.getList()
    },
    methods: {
      getList() {
        list(this.search).then(res => {
          if (res.code === 200) {
            this.searchList = this.searchList.concat(res.result.records)
            this.total = res.result.total
          }
        })
      },
      toDetail(id) {
        uni.navigateTo({
          url: `/pages/business/detail/Index?id=${id}`,
        })
      },
    },
  }
</script>
<style lang="less" scoped>
  .container {
    .list-content {
      width: 100%;
      padding: 0 30upx 120upx 30upx;
      box-sizing: border-box;
      .list-item {
        margin-top: 30upx;
        box-shadow: 0px 1px 7px 0px rgba(132, 202, 187, 0.3);
        background: #fff;
        padding: 20upx 15upx;
        box-sizing: border-box;
        .company-name {
          font-size: 34upx;
          font-weight: 600;
        }
        .com-info {
          margin-top: 20upx;
          color: #999;
          font-size: 28upx;
          word-break: break-all;
          text {
            color: #1678ff;
          }
        }
      }
    }
    .bottom-btn {
      position: fixed;
      bottom: 0;
      width: 100%;
      padding: 25upx 0;
      text-align: center;
      background: #1678ff;
      color: white;
      font-size: 16px;
    }
  }
</style>
